<?php
/**
 * Created by PhpStorm.
 * User: a
 * Date: 2016/6/1
 * Time: 10:12
 */
namespace Admin\Model;
use Think\Model;
class CustreferenceModel extends Model{
    protected $trueTableName = 'bypal_cust_reference';

    public function select_count_new_file($cust_id){
        $now_time=date("Y-m-d",time());
        $sql="select IFNULL(count(t2.id),0) file_count from bypal_cust_reference t1
        left join bypal_cust_referencefile t2 on t1.ref_id=t2.ref_id where t1.ref_custid='$cust_id' and t2.create_time>'$now_time'";
        $Model = new \Think\Model();
        $values=$Model->query($sql);
        return $values[0]["file_count"];
    }

    public function select_reference_bycust($cust_id){
        $sql="select t2.ref_annex from bypal_cust_reference t1 left join bypal_cust_referencefile t2 on t1.ref_id=t2.ref_id where ref_custid=$cust_id";
        $Model = new \Think\Model();
        $values=$Model->query($sql);
        return $values;
    }
}